import { Component, OnInit, Input, Injector } from '@angular/core';
import { HttpClient, HttpRequest, HttpResponse } from "@angular/common/http";
import { BehaviorSubject ,  Observable } from 'rxjs';
import { debounceTime ,  map ,  switchMap ,  filter } from 'rxjs/operators';
import { Router, ActivatedRoute, NavigationExtras } from '@angular/router';
import { NzMessageService, NzModalRef, NzModalService, UploadFile } from 'ng-zorro-antd';
import { importExpr } from '@angular/compiler/src/output/output_ast';
import { environment } from 'environments/environment';
import {
    PagedResultDto, ClassInfoOutput, PagerSearchInput, HttpService, BaseComponentConfig,
    CustomNavigation, KeyValueOutput, SearchValue
} from '../../..';
import { NgZorroPageBaseComponent } from '../../../core/ng-zorro-page-base-component/ng-zorro-page-base-component.component';
import { StudentJoinCourseOutput } from '../../../core/model/StudentJoinCourseDto';
import { isNumber } from 'util';
import { AuthService } from "../../../core/service/auth.service";
@Component({
    selector: 'app-course-score',
    templateUrl: './course-score.component.html',
    styleUrls: ['../../../core/ng-zorro-page-base-component/ng-zorro-page-base-component.component.scss']
})
export class CourseScoreComponent extends NgZorroPageBaseComponent implements OnInit {
    listUrl = 'ClassInfo/GetClassByName';
    searchChange$ = new BehaviorSubject(new SearchValue('', ''));
    optionList = [];
    selectedUser;
    // 开始演练
    startDrillId;
    confirmModal: NzModalRef;
    /**
     * 是否从远程获取数据
     */
    isLoading = false;

    onSearch(value: string, url: string): void {
        this.isLoading = true;
        this.searchChange$.next(new SearchValue(value, this.listUrl));
    }

    constructor(
        injecter: Injector,
        private modal: NzModalService,
        public httpService: HttpService,
        public router: Router,

        public http: HttpClient) {
        super(injecter,
            new BaseComponentConfig(
                "Course/GetCourseScore",
                "",
                "",
                "",
                "",
                "id",
                "",
                "课程打分",
                [],
                "Id",
                { Edit: false, Dell: false },
            ));
    }

    ngOnInit() {
        this.isSpinning = true;
        this.route.queryParamMap
            .pipe(map(params => params.get('id') || null))
            .subscribe(e => {
                this._pKeyFieldValue = this.route.snapshot.params['id'];
                if (!this._pKeyFieldValue) {
                    this.message.error('无法确定主键信息!');
                } else {
                    this.isSpinning = false;
                }
                this.IniObserver.subscribe(sb => {
                    this.getEntityList();
                });
            });
    }

    // 详情
    async seeReport(value: any) {
        // this.httpService.get<any>('Course/downReport?id='+value.id);    
    }
    // 编辑
    async editScore(id) {
        this.router.navigate(['app/courseScoreEdit', id]);
    }
    // 删除
    async deleteNotice(id) {
        this.confirmModal = this.modal.confirm({
            nzTitle: '是否要删除通知?',
            nzContent: '点击确定后，此通知的信息将被删除。',
            nzOnOk: () => {
                this.httpService.get<any>('Notice/DeleteNotice?id=' + id);
                location.reload();
            },
            nzOnCancel: () => {

            }
        });
    }
}
